<?php

namespace app\api\controller;

use app\common\controller\Frontend;

/**
 * 新闻
 */
class News extends Frontend
{
    protected array $noNeedLogin = ['*'];

    /**
     * 获取新闻列表
     * @return void
     * @throws \think\db\exception\DbException
     */
    public function lst(): void
    {
        $newsModel = new \app\common\model\News();
        $res = $newsModel
            ->order("top", "desc")
            ->order("publish_time", "desc")
            ->where("status", 1)
            ->paginate();
        $this->success("新闻", $res);
    }

    /**
     * 新闻详情
     * @return void
     */
    public function info(): void
    {
        $id = $this->request->get("id");
        $newsModel = new \app\common\model\News();
        $res = $newsModel->find($id);
        $this->success("新闻详情", $res);
    }

}